Added error handling and fixed position property