Nim code a bit cleaner and faster again

Should be better like this.