refactored the whole code, redesigned ui