Added some new functions in filter.R. Also, latest code incorporates both train and valid files.