Refactored code to remove Java Warnings