Removing uneasier code and added type check