fix code according to comments by @josenava