Added better comments and made function names consistent