fixing windows bombing due to bounds checking in at function

Signed-off-by: David Devaney <d_devaney@hotmail.co.uk>