Updated for use with rails