Main method implemented  and bug fixing