Adds checks for proper parameters and refactoring