revamped the whole main
fixed typo while printing error