added range function and fixed x domain