Fixed the moveToTop and moveToBottom functions (thanks Lamberto!)