added akshay's code and modified upload as well as main method