A bug is when code output differs from intended output. To find out why so... You need to know *exactly* what the code is doing. That's the only solid way to diagnose.