Fix return value and fix arguments check