final

finalized code and added comments