R Programming: PA1 refactoring