Merged with Emily's code + more validation