Fix some errors and logic of the code

Signed-off-by: Emirrah Hazelle Dogelio <em.dogelio@teamcodeflux.com>