Added console.log to if statement

Changed the log to print only in if or else occurs and added the final
comments