calculate length (not working yet)