updated code for main