removed duplicate isValidWord and fixed small bugs