Finalize project

+ Fixed some minor bugs
+ add valid/invalid image
+ refactor code