copied aman's code to main source