Updated for usage with the main code. 

Need implementation of the code for phase2