Fixing sigmoid to handle arrays correctly