Added commenting and documentation, Added thread sleep to fit 500ms