Fixes #3. Created a median function