Main script added and bugs fixed
Main script added