removed unnecessary type conversion
small refactor
added base case test