updated with proper comments and added bubble sort