-updated to correctly swap between little and host endian