moved code for final